{% extends "base.html" %}

{% block content %}
<div class="container mt-5">
    <h2 class="mb-4 text-center" style="font-weight: 600; color: #333;">编辑郑码码表</h2>
    <form method="post" style="max-width: 600px; margin: 0 auto;">
        <div style="margin-bottom: 1.5rem;">
            <label for="hanzi" style="display: block; font-weight: bold; margin-bottom: 0.5rem;">汉字:</label>
            <input type="text" name="hanzi" id="hanzi" value="{{ row['hanzi'] }}"
                style="width: 100%; padding: 0.5rem; border: 1px solid #ccc; border-radius: 5px;" required>
        </div>

        <div style="margin-bottom: 1.5rem;">
            <label for="quanma" style="display: block; font-weight: bold; margin-bottom: 0.5rem;">全码:</label>
            <input type="text" name="quanma" id="quanma" value="{{ row['quanma'] }}"
                style="width: 100%; padding: 0.5rem; border: 1px solid #ccc; border-radius: 5px;" required>
        </div>

        <div style="margin-bottom: 1.5rem;">
            <label for="pinyin" style="display: block; font-weight: bold; margin-bottom: 0.5rem;">拼音:</label>
            <input type="text" name="pinyin" id="pinyin" value="{{ row['pinyin'] }}"
                style="width: 100%; padding: 0.5rem; border: 1px solid #ccc; border-radius: 5px;" required>
        </div>

        <div style="margin-bottom: 1.5rem;">
            <label for="jieshi" style="display: block; font-weight: bold; margin-bottom: 0.5rem;">解释:</label>
            <input type="text" name="jieshi" id="jieshi" value="{{ row['jieshi'] }}"
                style="width: 100%; padding: 0.5rem; border: 1px solid #ccc; border-radius: 5px;" required>
        </div>

        <div style="margin-bottom: 1.5rem;">
            <label for="yima" style="display: block; font-weight: bold; margin-bottom: 0.5rem;">第一码:</label>
            <input type="text" name="yima" id="yima" value="{{ row['yima'] }}"
                style="width: 100%; padding: 0.5rem; border: 1px solid #ccc; border-radius: 5px;">
        </div>

        <div style="margin-bottom: 1.5rem;">
            <label for="erma" style="display: block; font-weight: bold; margin-bottom: 0.5rem;">第二码:</label>
            <input type="text" name="erma" id="erma" value="{{ row['erma'] }}"
                style="width: 100%; padding: 0.5rem; border: 1px solid #ccc; border-radius: 5px;">
        </div>

        <div style="margin-bottom: 1.5rem;">
            <label for="sanma" style="display: block; font-weight: bold; margin-bottom: 0.5rem;">倒数第二码:</label>
            <input type="text" name="sanma" id="sanma" value="{{ row['sanma'] }}"
                style="width: 100%; padding: 0.5rem; border: 1px solid #ccc; border-radius: 5px;">
        </div>

        <div style="margin-bottom: 1.5rem;">
            <label for="sima" style="display: block; font-weight: bold; margin-bottom: 0.5rem;">末码:</label>
            <input type="text" name="sima" id="sima" value="{{ row['sima'] }}"
                style="width: 100%; padding: 0.5rem; border: 1px solid #ccc; border-radius: 5px;">
        </div>
        
        <div style="margin-bottom: 2rem;">
            <label for="danzi" style="display: inline-block; font-weight: bold; margin-right: 0.5rem;">是否单字(与词组区分开):</label>
            <input type="checkbox" name="danzi" id="danzi" value="1" {% if row['danzi']==1 %}checked{% endif %}
                style="transform: scale(1.2); vertical-align: middle;">
            <!-- <div style="display: inline-block; font-weight: bold; margin-right: 0.5rem;"></div> -->
        </div>

        <div style="display: flex; justify-content: space-between; align-items: center;">
            <button type="submit"
                style="background-color: #007bff; color: #fff; padding: 0.5rem 1rem; border: none; border-radius: 5px; cursor: pointer; font-size: 1rem;">
                更新
            </button>
            <a href="{{ url_for('view', id=row['id']) }}"
                style="background-color: #007bff; color: #fff; padding: 0.5rem 1rem; border: none; border-radius: 5px; text-align: center; font-size: 1rem; text-decoration: none; display: inline-block;">
                查看
            </a>
        </div>
        
    </form>
</div>
{% endblock %}